﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Avalonia.Data.Converters;
using MinecraftEnchantCalculator.Data.Entity;

namespace MinecraftEnchantCalculator.Converters.Xaml;

public class EnchantListConverter : IValueConverter
{
  public object? Convert(
    object? value, Type targetType, object? parameter, CultureInfo culture
  )
  {
    if (value is not List<Enchantment> encList)
      return null;

    var encStr = encList.Select(x => $"{x.Name} {RomanNumeralConverter.ToRoman(x.Level)}");
    return string.Join(" + ", encStr);
  }

  public object? ConvertBack(
    object? value, Type targetType, object? parameter, CultureInfo culture
  )
  {
    throw new NotImplementedException();
  }
}